
import Mock from 'mockjs'

// 展车订单制作
const belowOrdCreateList = [
  {
    isBelowOrdStatus: '已录入',
    batchNum: '@string("upper", 6)',
    principalName: '@cname',
    principalPhone: '13342414111',
    creator: '@cname',
    createTime: '@now',
    planSCarQuantity: '@natural(1, 100)',
    actualSCarQuantity: '@natural(1, 100)',
    total: '',
    remark: ''
  },
  {
    isBelowOrdStatus: '已录入',
    batchNum: '@string("upper", 6)',
    principalName: '@cname',
    principalPhone: '13125334232',
    creator: '@cname',
    createTime: '@now',
    planSCarQuantity: '@natural(1, 100)',
    actualSCarQuantity: '@natural(1, 100)',
    total: '',
    remark: ''
  },
  {
    isBelowOrdStatus: '已录入',
    batchNum: '@string("upper", 6)',
    principalName: '@cname',
    principalPhone: '13125434234',
    creator: '@cname',
    createTime: '@now',
    planSCarQuantity: '@natural(1, 100)',
    actualSCarQuantity: '@natural(1, 100)',
    total: '',
    remark: ''
  },
  {
    isBelowOrdStatus: '已录入',
    batchNum: '@string("upper", 6)',
    principalName: '@cname',
    principalPhone: '13125334265',
    creator: '@cname',
    createTime: '@datetime',
    planSCarQuantity: '@natural(1, 100)',
    actualSCarQuantity: '@natural(1, 100)',
    total: '',
    remark: ''
  }
]

// 展车订单查询
const belowOrdCreateQueryByPage = Mock.mock({
  result: '1',
  msg: '',
  data: {
    belowOrdCreateQueryByPage: {
      result: '1',
      msg: '',
      pageindex: 1,
      pagesize: 1000,
      pages: 1,
      records: 3,
      rows: belowOrdCreateList
    }
  }
})

export default [
  // 展车订单制作查询
  {
    url: '/ve/belowOrdCreate',
    type: 'post',
    response: config => {
      var returnList = belowOrdCreateList
      // 查询条件过滤
      var params = config.body
      if (params) {
        if (params.batchNum !== '') {
          returnList = returnList.filter(o => o.batchNum === params.batchNum)
        }
        if (params.principalName !== '') {
          returnList = returnList.filter(o => o.principalName.indexOf(params.principalName) > -1)
        }
        if (params.principalPhone !== '') {
          returnList = returnList.filter(o => o.principalPhone === params.principalPhone)
        }
        if (params.orderTime !== '') {
          returnList = returnList.filter(o => o.orderTime === params.orderTime)
        }
        if (params.createTime !== '') {
          returnList = returnList.filter(o => o.createTime === params.createTime)
        }
      }
      // 分页过滤
      returnList.forEach((item, index) => {
        item['index'] = index
      })
      console.info(returnList)
      const minIndex = (config.body.pageIndex - 1) * config.body.pageSize
      const maxIndex = minIndex + config.body.pageSize
      returnList = returnList.filter(o => o.index >= minIndex && o.index < maxIndex)
      return {
        'msg': '',
        'result': '1',
        'rowcount': belowOrdCreateList.length,
        'rows': returnList
      }
    }
  },

  // 展车订单制作
  {
    url: '/ve/belowOrdCreate',
    type: 'post',
    response: config => {
      return {
        'result': '1',
        'rows': belowOrdCreateList
      }
    }
  },

  // 展车订单查询
  {
    url: '/ve/belowInfoMock',
    type: 'post',
    response: config => {
      return belowOrdCreateQueryByPage
    }
  },

  // 车型配置
  {
    url: '/ve/carType',
    type: 'post',
    data: {},
    response: config => {
      const { pageSize } = config.body
      return {
        'result': '1',
        'msg': 'Success',
        'rows': Array(pageSize).fill({
          id: '@id',
          carSeriesCode: '@string("upper", 6)',
          carSeriesName: '东风XX',
          carTypeCode: 'HFJEWH',
          'carTypeName|1': ['俊风ER30', '俊风E11K', '御风S16', '御风', '御风EV', '东风皮卡'],
          carConfigCode: 'AAAAAA',
          'carConfigName|1': ['东风', '启辰', '东风']
        })
      }
    }
  },
  // 门店选择
  {
    url: '/ve/belowStoreSelect',
    type: 'post',
    data: {},
    response: config => {
      const { pageSize } = config.body
      return {
        'result': '1',
        'msg': 'Success',
        'rows': Array(pageSize).fill({
          id: '@id',
          storeCode: 'GHDGSA',
          storeName: '广州体验中心',
          storeTypeName: '体验中心',
          storeGenera: '直营店',
          operatingStatus: '营业'
        })
      }
    }
  },

  // 展车订单设置
  {
    url: '/ve/belowConfig',
    type: 'post',
    data: {},
    response: config => {
      const { pageSize } = config.body
      return {
        'result': '1',
        'msg': 'Success',
        'rows': Array(pageSize).fill({
          id: '@id',
          isBelow: '是',
          belowOwner: '@cname',
          ownerEmail: '@email',
          ownerPhone: /^1[35789]{10}$/
        })
      }
    }
  },

  // 展车订单配车
  {
    url: '/ve/belowOrdCar',
    type: 'post',
    data: {},
    response: config => {
      const { pageSize } = config.body
      return {
        'result': '1',
        'msg': 'Success',
        'rows': Array(pageSize).fill({
          id: '@id',
          batchNum: '@string("upper", 6)',
          carOrder: '@string("upper", 6)',
          carStatus: '待配车',
          VINCode: '20314-134',
          'deliveryCity|1': ['武汉', '广州', '上海'],
          'storeGenera|1': ['直营店', '加盟店'],
          'deliveryStore|1': ['武汉交付门店', '广州交付门店', '上海交付门店'],
          belowStore: '广州体验中心',
          principalName: '@cname',
          principalPhone: /^1[35789]{10}$/,
          creator: '@cname',
          createTime: '@now',
          'isEnable|1': ['1', '0']
        })
      }
    }
  },

  {
    // 展车订单制作-新增订单保存
    url: '/ve/belowOrdCreate/edit',
    type: 'post',
    data: {},
    response: config => {
      // let {pageSize} = config.body
      return {
        'result': '1',
        'msg': 'Success'
      }
    }
  },
  {
    // 展车订单制作-新增订单
    url: '/ve/belowOrdCreate/add',
    type: 'post',
    data: {},
    response: config => {
      // let {pageSize} = config.body
      return {
        'result': '1',
        'msg': 'Success'
      }
    }
  }
]
